<admintpl file="header" />
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a>修改小组</a></li>
        </ul>
        <form action="{:U('Usergroup/edit_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">

			<fieldset>
				<div class="control-group">
					<label class="control-label" for="input-signature">小组名称</label>
					<div class="controls">
                        <input type="hidden" name="id" value="{$ugroup.id}" />
						<input type="text" value="{$ugroup.name}" readonly="readonly" maxlength="16">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">小组介绍</label>
					<div class="controls">
						<input type="text" name="explanation" required value="{$ugroup.explanation}" maxlength="64">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">所在省份</label>
					<div class="controls">
						<input type="text" readonly="readonly" value="{$province.name}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">创建时间</label>
					<div class="controls">
						<input type="text" readonly="readonly" value="{$ugroup.create}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature">小组LOGO</label>
					<div class="controls">
						<if condition="$ugroup['logo']">
							<input type="hidden" name="logo" value="{$ugroup.logo}" width="128"/>
							<img src="{$urlimg}{$ugroup.logo}" name="logo">
							<a href="{:U('Usergroup/del_img',array('id'=>$ugroup['id']))}"class="btn">删除图片</a>
			        	</if>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="input-signature"></label>
					<div class="controls">
						<img src="" id="logoimg">
						<input type="file" name="newlogo" id="logofile" accept="image/*"/>
					</div>
				</div>
				<div class="form-actions">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:L('SAVE')}</button>
				</div>
			</fieldset>
        </form>
    </div>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script type="text/javascript">
	$("#logofile").change(function(){
		var objUrl = getObjectURL(this.files[0]) ;
		console.log("objUrl = "+objUrl) ;
		if (objUrl) {
			$("#logoimg").attr("src", objUrl) ;
			$("#logoimg").attr("width", "128") ;
		}
	}) ;
	function getObjectURL(file) {
		var url = null ;
		if (window.createObjectURL!=undefined) { // basic
			url = window.createObjectURL(file) ;
		} else if (window.URL!=undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file) ;
		} else if (window.webkitURL!=undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file) ;
		}
		return url ;
	}
    </script>
</body>
</html>
